home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / prog / pas_all.zip / TI992.ASC < prev    next >
Text File  |  1992-04-28  |  3KB  |  199 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  Turbo Pascal                           NUMBER  :  992
  9.   VERSION  :  1.0
  10.        OS  :  Windows
  11.      DATE  :  April 28, 1992                           PAGE  :  1/3
  12.  
  13.     TITLE  :  Use Collections and ListBoxes.
  14.  
  15.  
  16.  
  17.  
  18.   {$X+}
  19.  
  20.   (*
  21.      The Resource file will only have one item in it. A dialog
  22.      with a listbox and an OK button. The listbox ID should be
  23.      101 and the OK Button ID should be 1. The name of the
  24.      dialog is NewDialog.
  25.   *)
  26.  
  27.   program Initialization_ListBox_with_Collection;
  28.  
  29.   {$R CollDlg.res}
  30.  
  31.   uses WinTypes, winprocs, wobjectb, strings, BWCC;
  32.  
  33.   var
  34.     st1,st2,st3: PChar;
  35.  
  36.   const
  37.     buttonid = 100;
  38.     listid = 101;
  39.  
  40.   type
  41.     Plbtrans =^Tlbtrans;
  42.     Tlbtrans = record
  43.       Strings: PStrCollection;
  44.       Selection: integer;
  45.     end;
  46.  
  47.   type
  48.     typePMyApp = ^TMyApp;
  49.     TMyApp = object(TApplication)
  50.       procedure InitMainWindow; virtual;
  51.     end;
  52.  
  53.     PMyMainWindow = ^TMyMainWindow;
  54.     TMyMainWindow = object(TWindow)
  55.       But: PButton;
  56.       Constructor Init(AName: PChar);
  57.       Destructor Done; virtual;
  58.       procedure SetUpWindow; virtual;
  59.       procedure TestButton(var Msg:TMessage);
  60.                     virtual id_First + ButtonId;
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.   PRODUCT  :  Turbo Pascal                           NUMBER  :  992
  75.   VERSION  :  1.0
  76.        OS  :  Windows
  77.      DATE  :  April 28, 1992                           PAGE  :  2/3
  78.  
  79.     TITLE  :  Use Collections and ListBoxes.
  80.  
  81.  
  82.  
  83.  
  84.     end;
  85.  
  86.   var
  87.     Buf: TlbTrans;
  88.  
  89.   procedure TMyApp.InitMainWindow;
  90.   begin
  91.     MainWindow:= New(PMyMainWindow, init('Main Window'));
  92.   end;
  93.  
  94.   constructor TMyMainWindow.Init(AName: PChar);
  95.   begin
  96.     TWIndow.Init(nil, AName);
  97.     but:= New(PButton,init(@self,ButtonId,'&Test',10,10,
  98.               50,50,false));
  99.   end;
  100.  
  101.   Destructor TMyMainWindow.Done;
  102.   { dispose of collection }
  103.   begin
  104.     TWindow.Done;
  105.     Dispose(But);
  106.     FreeMem(St2,8);
  107.     FreeMem(St3,8);
  108.   end;
  109.  
  110.   procedure TMyMainWindow.SetUpWindow;
  111.   begin
  112.     TWindow.SetUpWindow;
  113.   end;
  114.  
  115.   procedure TMyMainWindow.TestButton(var Msg: TMessage);
  116.   { Setup DialogBox with a ListBox }
  117.   var
  118.     TheDialog: PDialog;
  119.     LB: PListBox;
  120.     S: PChar;
  121.   begin
  122.     TheDialog:= new(PDialog,init(@Self,'NewDialog'));
  123.     New(LB,InitResource(TheDialog,101));
  124.     { create collection }
  125.     Buf.Strings:=New(PStrCollection, init(10,10));
  126.     GetMem(St1,8);
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.   PRODUCT  :  Turbo Pascal                           NUMBER  :  992
  141.   VERSION  :  1.0
  142.        OS  :  Windows
  143.      DATE  :  April 28, 1992                           PAGE  :  3/3
  144.  
  145.     TITLE  :  Use Collections and ListBoxes.
  146.  
  147.  
  148.  
  149.  
  150.     StrCopy(St1,'Hello');
  151.     Buf.Strings^.Insert(St1);
  152.     GetMem(st2,8);
  153.     StrCopy(St2,'Goodbye');
  154.     Buf.Strings^.Insert(St2);
  155.     GetMem(st3,8);
  156.     StrCopy(St3,'Hey');
  157.     Buf.Strings^.Insert(St3);
  158.     Buf.Selection:=1;
  159.     TheDialog^.TransferBuffer:= @Buf;
  160.     Application^.ExecDialog(TheDialog);
  161.     GetMem(S, 8);
  162.     S:= buf.Strings^.at(Buf.Selection);
  163.     MessageBox(hWindow,S,'Data from ListBox',mb_Ok);
  164.     FreeMem(S, 8);
  165.   end;
  166.  
  167.   var
  168.     MyApp: TMyApp;
  169.   begin
  170.     MyApp.Init('MyApp');
  171.     MyApp.Run;
  172.     MyApp.Done;
  173.   end.
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.